<#escape x as (x)!?html>
    <#import "/page/Utils.ftl" as utils/>
    <#import "/page/synxisadapter/EnumUtils.ftl" as enumUtils/>
<head>
    <script type="text/javascript">
        var menuId = "Settings_Hotel";

        function add() {
            $("#addForm").submit();
        }
        function import_hotel() {
            $("#importForm").submit();
        }
        function edit(e) {
            var tr = e.parent().parent();
            var id = tr.find("input[@name='id']").val();

            $("#editForm").find("input[@name='id']").val(id);
            $("#editForm").submit();
        }

    </script>
</head>
<body>

<form id="addForm" method="GET" action="add.action">
</form>
<form id="importForm" method="GET" action="importView.action">
</form>
<form id="editForm" method="GET" action="edit.action">
    <input type="hidden" name="id"/>
</form>

<table>
    <caption>
        <div class="tools border">Hotel Query:
            <input type="button" value="Add" class="btn" onclick="add()"/>
            <input type="button" value="Import" class="btn" onclick="import_hotel()"/>
        </div>
    </caption>
</table>
<table>
    <caption>
        <div class="tools border">
            <form id="mainForm" action="query.action" method="GET">
                <input name="page" type="hidden"/>
                <input name="count" type="hidden"/>
                <table class="form_table">
                    <tr>
                        <td class="key">Synxis ID:&nbsp;</td>
                        <td class="value">
                            <input type="text" class="text" value="${condition.id?html}"
                                   name="condition.id"> &nbsp;
                        </td>
                        <td class="key">Name:&nbsp;</td>
                        <td class="value">
                            <input type="text" class="text" value="${condition.name?html}"
                                   name="condition.name"> &nbsp;
                        </td>
                        <td class="key">Passport:&nbsp;</td>
                        <td class="value">
                            <input type="text" class="text" value="${condition.passport?html}"
                                   name="condition.passport"> &nbsp;
                        </td>
                        <td class="key">Status:&nbsp;</td>
                        <td class="value">
                            <select class="select" name="condition.status">
                                <option value="">ALL</option>
                                <#list enumUtils.enumHotelStatus() as status>
                                    <option value="${status}" ${(condition.status==status)?string("selected='selected'","")}>${status}</option>
                                </#list>
                            </select> &nbsp;
                        </td>
                    </tr>
                    <tr>
                        <td colspan="8" align="right"><input type="submit" value="Search" class="btn">&nbsp;</td>
                    </tr>
                </table>
            </form>
        </div>

    </caption>
    <thead>
    <tr>
        <th>Synxis ID</th>
        <th>Name</th>
        <th>Passport</th>
        <th>ProviderPassport</th>
        <th>ProviderName</th>
        <th>Status</th>
        <th>Operation</th>
    </tr>
    </thead>
    <tbody>
        <#list hotels as hotel>
        <tr class="${(hotel_index%2==0)?string('even','odd')}">
            <td>${hotel.id}<input type="hidden" name="id" value="${hotel.id}"/>&nbsp;</td>
            <td>${hotel.name}&nbsp;</td>
            <td>${hotel.passport}&nbsp;</td>
            <td>${hotel.providerPassport}&nbsp;</td>
            <td>${hotel.providerName}&nbsp;</td>
            <td>${hotel.status}&nbsp;</td>
            <td><input type="button" value="Edit" class="btn" onclick="edit($(this))"/>&nbsp;</td>
        </tr>
        </#list>
    <tbody>
    <tfoot>
        <#if paginator?exists>
        <tr>
            <td colspan="100" class="tools">
                <div class="paginator">
                <@utils.paging paginator "navigate" 20/>
                    <script type="text/javascript">
                        function navigate(page, count) {
                            $("#mainForm > input[name='page']").val(page);
                            $("#mainForm > input[name='count']").val(count);
                            $("#mainForm").submit();
                        }
                    </script>
                </div>
                &nbsp;</td>
        </tr>
        </#if>
    </tfoot>
</table>
</body>
</#escape>